home *** CD-ROM | disk | FTP | other *** search
- class DataObject
- {
- var arrElements;
- var indexOne;
- var indexTwo;
- function DataObject()
- {
- var _loc3_ = this.RandNum(55,66);
- this.arrElements = new Array(_loc3_);
- var _loc2_ = 0;
- while(_loc2_ < _loc3_)
- {
- this.arrElements[_loc2_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- this.indexOne = -1;
- this.indexTwo = -1;
- }
- function Set(dataValue)
- {
- var _loc6_ = Math.round(Math.random() * dataValue);
- var _loc7_ = dataValue - _loc6_;
- this.indexOne = this.RandNum(0,this.arrElements.length - 4);
- this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
- if(this.indexOne == this.indexTwo)
- {
- if(this.indexOne == this.arrElements.length - 1)
- {
- this.indexTwo = this.indexOne - 1;
- }
- else
- {
- this.indexTwo = this.indexOne + 1;
- }
- }
- var _loc5_ = dataValue / (this.arrElements.length - 2);
- var _loc4_ = dataValue;
- var _loc9_ = this.arrElements.length;
- var _loc2_ = 0;
- while(_loc2_ < this.arrElements.length)
- {
- if(_loc2_ == this.indexOne)
- {
- this.arrElements[_loc2_] = _loc6_;
- }
- else if(_loc2_ == this.indexTwo)
- {
- this.arrElements[_loc2_] = _loc7_;
- }
- else
- {
- var _loc3_ = 0;
- if(_loc4_ > 0)
- {
- _loc3_ = Math.round(Math.random() * _loc5_ + _loc5_ * 0.5);
- if(_loc3_ > _loc4_)
- {
- _loc3_ = _loc4_;
- }
- if(_loc2_ == this.arrElements.length - 1)
- {
- _loc3_ = _loc4_;
- }
- _loc4_ -= _loc3_;
- }
- this.arrElements[_loc2_] = _loc3_;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function mSet(dataValue)
- {
- var _loc7_ = 0;
- while(_loc7_ < 10)
- {
- var _loc5_ = Math.round(Math.random() * dataValue);
- var _loc8_ = dataValue - _loc5_;
- this.indexOne = this.RandNum(0,this.arrElements.length - 4);
- this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
- if(this.indexOne == this.indexTwo)
- {
- if(this.indexOne == this.arrElements.length - 1)
- {
- this.indexTwo = this.indexOne - 1;
- }
- else
- {
- this.indexTwo = this.indexOne + 1;
- }
- }
- var _loc4_ = dataValue / (this.arrElements.length - 2);
- var _loc10_ = dataValue;
- var _loc9_ = this.arrElements.length;
- var _loc2_ = 0;
- while(_loc2_ < this.arrElements.length)
- {
- if(_loc2_ == this.indexOne)
- {
- this.arrElements[_loc2_] = _loc5_;
- }
- else if(_loc2_ == this.indexTwo)
- {
- this.arrElements[_loc2_] = _loc8_;
- }
- else
- {
- var _loc3_ = 0;
- _loc3_ = Math.round(Math.random() * (_loc4_ * 1.23) + _loc4_ * 0.75);
- this.arrElements[_loc2_] = _loc3_;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(this.Get() == -1)
- {
- break;
- }
- _loc7_ = _loc7_ + 1;
- }
- }
- function Get()
- {
- var _loc3_ = 0;
- var _loc4_ = 0;
- var _loc2_ = 0;
- while(_loc2_ < this.arrElements.length)
- {
- if(_loc2_ == this.indexOne)
- {
- _loc3_ += this.arrElements[_loc2_];
- }
- else if(_loc2_ == this.indexTwo)
- {
- _loc3_ += this.arrElements[_loc2_];
- }
- else
- {
- _loc4_ += this.arrElements[_loc2_];
- }
- _loc2_ = _loc2_ + 1;
- }
- if(_loc3_ == _loc4_)
- {
- return _loc3_;
- }
- return -1;
- }
- function Store()
- {
- var _loc2_ = this.arrElements.slice();
- _loc2_.splice(2,0,this.indexOne);
- _loc2_.splice(7,0,this.indexTwo);
- return _loc2_;
- }
- function Load(originalArray)
- {
- this.indexOne = originalArray[2];
- this.indexTwo = originalArray[7];
- delete this.arrElements;
- this.arrElements = originalArray.slice();
- this.arrElements.splice(7,1);
- this.arrElements.splice(2,1);
- }
- function RandNum(minVal, maxVal)
- {
- return Math.round(Math.random() * (maxVal - minVal)) + minVal;
- }
- }
-